package com.ljkj.cordial.chat.activity;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.widget.TextView;

import com.ljkj.cordial.chat.R;
import com.ljkj.cordial.chat.base.BaseActivity;
import com.ljkj.cordial.chat.bean.Canstants;
import com.ljkj.cordial.chat.dao.notify.BusinessLeaveTable;
import com.ljkj.cordial.chat.widget.PuzzleImageView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @description:
 * @author: Panwei
 * @date: 2020/1/3 10:23
 */
public class LeaveGroupActivity extends BaseActivity {

    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_id)
    TextView tvId;
    @BindView(R.id.iv_avatar)
    PuzzleImageView ivAvatar;
    @BindView(R.id.tv_group_name)
    TextView tvGroupName;
    @BindView(R.id.tv_append_info)
    TextView tvAppendInfo;

    private BusinessLeaveTable info;

    @Override
    public int getContentLayoutId() {
        return R.layout.activity_leave_group;
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
        getToolbar().setTitle("退出群");
        info = (BusinessLeaveTable) getIntent().getSerializableExtra(Canstants.KEY_LEAVE_INFO);
        if (info != null) {
            tvName.setText(info.getTargetUserName());
            tvId.setText(info.getTargetUserId());
            tvGroupName.setText(info.getTargetGroupName());
            tvAppendInfo.setText(info.getTargetLeave());
            if (!TextUtils.isEmpty(info.getAvatarUrl())) {
                if (info.getAvatarUrl().contains(",")) {
                    ivAvatar.setImageBackGround(info.getAvatarUrl(), info.getTargetUserId());
                } else {
                    ivAvatar.setFriendUrl(info.getAvatarUrl(), info.getTargetUserId());
                }
            }
        }
    }

    public static void jumpTo(Context activity, BusinessLeaveTable table) {
        Intent intent = new Intent(activity, LeaveGroupActivity.class);
        intent.putExtra(Canstants.KEY_LEAVE_INFO, table);
        activity.startActivity(intent);
    }
}
